package com.hfh.reflect;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author hfh
 * @Date 2022 09 14 16 36
 **/
public class Work2 {
    public static void main(String[] args) throws NoSuchFieldException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        List<Integer> list = new ArrayList<>();
        Method method = ArrayList.class.getDeclaredMethod("add", Object.class);
        method.invoke(list,"字符串");
        System.out.println(list.get(0));
    }
}